function toWhere(path) {
    let hash = location.hash ? location.hash.split(/^#/)[1] : ""; // 旧路径
    //新相对路径
    //   ../../
    let [up, pathArray] = path.split("/").reduce(
        (a, b) => {
            if (b === "..") {
                a[0] += 1;
            } else {
                a[1].push(b);
            }
            return a;
        },
        [0, []]
    );
    //新对旧路径操作
    [...Array(up)].forEach((i) => {
        hash = hash.replace(/[^\/]*?$|[^\/]*?\/$/, "");
    });
    // ./jspider
    hash = hash + pathArray.join("/").replace(/^\.*/, "");

    //给予 hash 值
    location.hash = hash;
    return hash;
}
export default toWhere;
